package com.linln.admin.insuranceoffer;

import com.linln.common.vo.JsonResult;
import com.linln.common.vo.PageResult;
import com.linln.component.shiro.ShiroUtil;
import com.linln.modules.insurance.domain.InsuranceOffer;
import com.linln.modules.insurance.service.InsuranceOfferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author : pengliang
 * @version V1.0
 * @Project: timo
 * @Package com.linln.admin.insuranceoffer
 * @Descriptio /**
 * @Project: timo
 * @Package com.linln.admin.insuranceoffer
 * @Description: TODO
 * @date Date : 2020年12月29日 17:13
 */
@Controller
@RequestMapping("insuranceOffer")
public class InsuranceOfferController {
    @GetMapping("/index")
    public String index() {
        return "/insuranceOffer/index";
    }

    @Autowired
    private InsuranceOfferService insuranceOfferService;

    @GetMapping
    @ResponseBody
    public PageResult<InsuranceOffer> getInsuranceOffer(@RequestParam(required = false, defaultValue = "0") Integer page, @RequestParam(required = false, defaultValue = "10") Integer limit, String ownerName, String ownerPhone, Boolean status) {
        return insuranceOfferService.getInsuranceOffer(page, limit, ownerName, ownerPhone, status);
    }


    @PostMapping
    @ResponseBody
    public JsonResult updateStatus(String ioId){
        return insuranceOfferService.updateInsuranceOfferStatus(ioId, ShiroUtil.getSubject().getId())?JsonResult.ok("更新成功"):JsonResult.error("更新失败");
    }

}
